package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import entity.User;

/**
 * Servlet implementation class HelloServlet
 */
public class HelloServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//getSession(true)  如果没有session 就会创建 session对象
		HttpSession session = request.getSession(true);
		
		User user = new User();
		user.setId(2);
		user.setUsername("admin999");
		user.setPwd("666");
		
		session.setAttribute("user", user);
/*		request.setAttribute("a", "abcdefg");
*/		
		System.out.println("HELLO!!!!");
	
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
